-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
332/Store slippage info on appData #629
Conversation
CLA Assistant Lite All Contributors have signed the CLA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the direction of this PR is good.
So you are happy if we start using JOITAI for new state? it looks to me simple to read, write, and share logic. Also simpler to later move some pieces to libraries to be reused.
0088bc9
to
55a1878
Compare
|
Hey @alfetopito , great job! Some tiny issues/questions from my side:
Thanks! |
There might be some unnecessary updates to the appDataHash, but the important part is that whatever is in the order matches what you see/sign. Is that the case? |
@alfetopito , the important part works great! I have just mentioned these edge cases to make sure they will not cause critical issues in future. |
Checked the 3 points:
For this 2 cases, the values are being reset, but not logged. The log only happens when there's an actual change. Screen.Recording.2022-06-20.at.16.49.08.mov
For this case, it's due to how the price quote is fetched. If you remove the console log filter you should see there is a fee quote update matching the appData update When that differs (from what's already store in the appData), it'll be updated |
3ba553f
to
b69dab7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greate PR. And happy with how you used jotai, I think doesn't change too much organization in terms of hooks/state/updaters\
WARNING! Still needs refactoring
WARNING! Needs to review if affiliate flow is still working as before
Most have been replaced by the correspondent sdk methods
* Updated stored types to contain lastAttempt rather than tryAfter * New helper function to check when we can try to upload to ipfs again * Improved logging for ipfs upload updater * Changed soft upload failures log level from debug to warn * Refactor: extracted helper function _actuallyUploadToIpfs * Refactor: Renamed BASE_TIME_BETWEEN_ATTEMPTS to BASE_FOR_EXPONENTIAL_BACKOFF
* Updated state/affiliate - Removed no longer needed state (appDataHash) - Added new status referralAddress.isActive - Updated associated actions, hooks and reducer - Updated AffiliateStatusCheck to use new state * Updated hooks/useAppData to use new state/affiliate state * Updated useEffect deps to prevent unecessary re-renders * Refactor: removed redundant variable * Fixed issue where invalid referral would not be tagged as so
* Added `localWarning` for PINATA keys * Displaying localWarning if any * Added alternative warning display: As a permanent toast notification * Refactor: Renamed WarningPopupContent `message` to `warning` * Added warning icon to toast notification * Moved localWarning from Header to state/application * Changed warning popup key to a more generic value * Removed banner with warning in favor of the popup notification
42ecff3
to
e625664
Compare
* Ignore quoteId when checking if the order is unfillable * Persiste quoteId from api to redux state * Add quoteId to GpTrade class * Pass quoteId down to appData * Include quoteId on order placement * Bumped cow-sdk to 0.0.15-RC.0
* Refactor: Replaced map upload queue with arrary * Refactor: Using slice(0) to clone array instead of spread operator * Refactor: using Array.some instead of Array.find As I do not need to the stored element
* Bumop quote metadata version * Added helper function to transfor Percent instances to bip string * Refactored appData utils functions to use new quote metadata schema Also changed the fn signature to accomodate different options if needed * Updated useAppData to use slippage in the quote metadata * Refactored useAppData interface * Removed code that is not related to slippageBips for quote metadata * Actually, _buildQuoteMetadata will never return undefined
* Increased upload to IPFS queue check interval to 1m * Try to upload docs added to the upload queue right away
* Refactor: renamed useAddress to useAffiliateAddress * Typo fix on comment * Fixed issue with affiliate not valid displayed when there was no affiliate * Refeset affiliate state whenever error is reset * Referral address cannot be null, but undefined 🤦
Summary
Part of #332
Edit 2022-07-01
No longer creating on appData per order.
Now stores the selected slippage, which will significantly reduce the amount of appData uploaded, while still capturing the original price.
Original description
Creating a new appDataHash for every order.
It's recalculated for every price quote.
It includes:
quote metadata (buy/sell amounts)
referrer metadata - if referral address is set and is valid
appCode - CowSwap or CowSwap-SafeApp
environemnt - local, dev, prod, barn, ens, etc
To Test
appData
pr
https://barn.api.cow.fi/mainnet/api/v1/orders/<orderId>
UploadToIpfs